package com.zx.notification.common.param;

import com.zx.validation.annotation.ParameterValidation;
import com.zx.validation.enums.DateTimeFormatEnum;
import com.zx.validation.enums.ValidateRulesEnum;
import com.zx.validation.groups.Create;
import com.zx.validation.groups.Query;
import com.zx.validation.groups.Update;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.Set;

/**
 * <p>
 * description: 系统通知参数 <br>
 * create: 2025-10-15
 * </p>
 *
 * @author zhou  xun
 */
@SuperBuilder
@AllArgsConstructor
@NoArgsConstructor
@Data
public class SystemNotificationsParam implements Serializable, Create, Update, Query {
    /**
     * 通知ID
     */
    @ParameterValidation(index = 0, desc = "通知ID", rules = {ValidateRulesEnum.NOT_NULL})
    private String id;

    /**
     * 接收用户ID
     */
    @ParameterValidation(index = 0, desc = "接收用户ID", rules = {ValidateRulesEnum.NOT_NULL})
    private String userId;

    /**
     * 模板编码
     */
    @ParameterValidation(index = 0, desc = "模板编码", rules = {ValidateRulesEnum.NOT_NULL})
    private String templateCode;

    /**
     * 通知标题
     */
    @ParameterValidation(index = 0, desc = "通知标题", rules = {ValidateRulesEnum.NOT_NULL})
    private String title;

    /**
     * 通知内容
     */
    @ParameterValidation(index = 0, desc = "通知内容", rules = {ValidateRulesEnum.NOT_NULL})
    private String content;

    /**
     * 业务类型
     */
    @ParameterValidation(index = 0, desc = "业务类型", rules = {ValidateRulesEnum.NOT_NULL})
    private String bizType;

    /**
     * 业务ID
     */
    private String bizId;

    /**
     * 业务链接
     */
    private String bizUrl;

    /**
     * 业务数据(JSON格式)
     */
    private String bizData;

    /**
     * 目标渠道: 实际发送的渠道列表，多个以逗号分隔，如: INBOX,WEBSOCKET,SMS
     */
    @ParameterValidation(index = 0, desc = "目标渠道", rules = {ValidateRulesEnum.NOT_NULL})
    private String targetChannels;

    /**
     * 创建时间
     */
    private LocalDateTime createTime;

    /**
     * 过期时间
     */
    private LocalDateTime expireTime;

    /**
     * 当前页码
     */
    @ParameterValidation(index = 0, desc = "当前页码", rules = {ValidateRulesEnum.NUMBER_MIN}, numberMin = 1)
    private Long pageNum;

    /**
     * 每页条数
     */
    @ParameterValidation(index = 0, desc = "每页条数", rules = {ValidateRulesEnum.NUMBER_MIN, ValidateRulesEnum.NUMBER_MAX}, numberMin = 1, numberMax = 1000)
    private Long pageSize;

    /**
     * 创建时间开始
     * 用于时间范围查询，查询大于等于该时间的记录
     */
    @ParameterValidation(index = 0, desc = "创建时间开始", rules = {ValidateRulesEnum.NULL_DATE_TIME}, dateFormat = DateTimeFormatEnum.DATE_TIME)
    private LocalDateTime createTimeStart;

    /**
     * 创建时间结束
     * 用于时间范围查询，查询小于等于该时间的记录
     */
    @ParameterValidation(index = 0, desc = "创建时间结束", rules = {ValidateRulesEnum.NULL_DATE_TIME}, dateFormat = DateTimeFormatEnum.DATE_TIME)
    private LocalDateTime createTimeEnd;

    @Override
    public Set<String> getCreateGroupFields() {
        return Set.of("userId", "templateCode", "title", "content", "bizType", "targetChannels");
    }

    @Override
    public Set<String> getUpdateGroupFields() {
        return Set.of("id");
    }

    @Override
    public Set<String> getQueryGroupFields() {
        return Set.of("pageNum", "pageSize", "createTimeStart", "createTimeEnd");
    }
}